package com.yuanzong.wuliu.service.business.customer.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.yuanzong.wuliu.common.vo.ApiResultPage;
import com.yuanzong.wuliu.mapper.business.customer.BusinessCustomerDaijiaxianMapper;
import com.yuanzong.wuliu.model.business.customer.BusinessCustomerDaijiaxian;
import com.yuanzong.wuliu.model.business.customer.bo.BusinessCustomerDaijiaxianPageByMapperBo;
import com.yuanzong.wuliu.model.business.customer.query.*;
import com.yuanzong.wuliu.service.business.customer.IBusinessCustomerDaijiaxianService;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;
import java.util.function.Function;
import java.util.stream.Collectors;

@Service("businessCustomerDaijiaxianService")
public class BusinessCustomerDaijiaxianServiceImpl extends ServiceImpl<BusinessCustomerDaijiaxianMapper, BusinessCustomerDaijiaxian> implements IBusinessCustomerDaijiaxianService {

    // 逻辑删除
    protected static final boolean logicalDeleted = false;

    @Autowired
    private BusinessCustomerDaijiaxianMapper businessCustomerDaijiaxianMapper;

    //========================================================================================//
    // Service服务接口操作
    //========================================================================================//

    @Override
    public List<BusinessCustomerDaijiaxian> querySubject(BusinessCustomerDaijiaxianListQuery query) throws Exception {
        List<BusinessCustomerDaijiaxian> businessCustomerDaijiaxianList = null;
        QueryWrapper<BusinessCustomerDaijiaxian> queryWrapper = new QueryWrapper<>();
        if (query.getCustomerId() != null) {
            queryWrapper.eq("customer_id", query.getCustomerId());
        }
        businessCustomerDaijiaxianList = super.getBaseMapper().selectList(queryWrapper);
        return businessCustomerDaijiaxianList;
    }

    @Override
    public ApiResultPage<BusinessCustomerDaijiaxian> pageSubject(BusinessCustomerDaijiaxianPageQuery query) throws Exception {
        ApiResultPage<BusinessCustomerDaijiaxian> businessCustomerDaijiaxianPageList = null;
        Page<BusinessCustomerDaijiaxian> businessCustomerDaijiaxianPage = new Page<>(query.getPageNum(), query.getPageSize());
        QueryWrapper<BusinessCustomerDaijiaxian> queryWrapper = new QueryWrapper<>();
        businessCustomerDaijiaxianPage = super.baseMapper.selectPage(businessCustomerDaijiaxianPage, queryWrapper);
        businessCustomerDaijiaxianPageList = ApiResultPage.create(query.getPageNum(), query.getPageSize(), businessCustomerDaijiaxianPage);
        return businessCustomerDaijiaxianPageList;
    }

    @Override
    public ApiResultPage<BusinessCustomerDaijiaxianPageByMapperBo> pageByMapper(BusinessCustomerDaijiaxianPageQuery query) throws Exception {
        Page<BusinessCustomerDaijiaxianPageByMapperBo> page = new Page<>(query.getPageNum(), query.getPageSize());
        page = businessCustomerDaijiaxianMapper.pageByMapper(page, query);
        ApiResultPage<BusinessCustomerDaijiaxianPageByMapperBo> apiResultPage = ApiResultPage.create(query.getPageNum(), query.getPageSize(), page);
        return apiResultPage;
    }

    //========================================================================================//
    // HTTP服务接口操作
    //========================================================================================//

    //========================================================================================//
    // extend methods
    //========================================================================================//


    //========================================================================================//
    // The end
    //========================================================================================//

}
